<? service('i18n')->import('profiler') ?>
<? $profiler = service('dbListener')->getProfiler() ?>
<div class="row">
    <div class="col-md-6">
        <div class="portlet green box">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-bug"></i> <?=__('Page Profiler')?>
                </div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                    <a href="javascript:;" class="remove"></a>
                </div>
            </div>
            <div class="portlet-body">
                <strong><?=__('Page Time:')?></strong>
                <font color="green"><?=num_format(microtime(true) - START_TIME, 6)?></font> <?=__('secs')?>,
                <strong><?=__('Usage Memory:')?></strong>
                <font color="green"><?=num_format((memory_get_usage() - START_MEMORY) / 1024, 2)?></font> kb
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="portlet green box">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-bug"></i> <?=__('Database Profiler')?>
                </div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                    <a href="javascript:;" class="remove"></a>
                </div>
            </div>
            <div class="portlet-body">
                <strong><?=__('Total Queries:')?></strong>
                <font color="green"><?=$profiler->getNumberTotalStatements()?></font>,
                <strong><?=__('Elapsed Time:')?></strong>
                <font color="green"><?=num_format($profiler->getTotalElapsedSeconds(), 6)?></font> <?=__('secs')?>
            </div>
        </div>
    </div>
    <div class="col-md-12">
        <div class="portlet blue box">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-bar-chart-o"></i> <?=__('SQL Queries')?>
                </div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                    <a href="javascript:;" class="remove"></a>
                </div>
            </div>
            <div class="portlet-body">
                <? foreach ($profiler->getProfiles() as $i => $profile): ?>
                <? $secs = $profile->getTotalElapsedSeconds() ?>
                <div style="font-family: Consolas,'Courier New';
                            color:<?=on($secs > 0.1, 'red', 'green')?>;
                            <?=on(($i + 1) < count($profiler->getProfiles()), 'border-bottom:1px dashed #ccc;')?>
                            font-size:11px;  margin-top:5px; padding-bottom:5px;">
                    <i><?=$profile->getSQLStatement()?> ;</i>
                    <font color="gray">-- <?=num_format($profile->getTotalElapsedSeconds(), 6)?></font>
                </div>
                <? endforeach; ?>
            </div>
        </div>
    </div>
    <div class="clearfix"></div>
</div>
